﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using Wcf._5Dev.SettlementExpenses.Domain;
using Wcf._5Dev.SettlementExpenses.Persistencia;

namespace Wcf._5Dev.SettlementExpenses
{
    public class ServiceSettlementExpenses : ISettlementExpenses
    {
        #region < Propiedades>

        private CostCenterDao costCenterDao = null;

        private CostCenterDao CostCenterDao
        {
            get
            {

                if (costCenterDao == null)
                    costCenterDao = new CostCenterDao();

                return costCenterDao;
            }
        }

        private CostConceptDao costConceptDao = null;

        private CostConceptDao CostConceptDao
        {
            get
            {

                if (costConceptDao == null)
                    costConceptDao = new CostConceptDao();

                return costConceptDao;
            }
        }

        private EmployeeDao employeeDao = null;

        private EmployeeDao EmployeeDao
        {
            get
            {

                if (employeeDao == null)
                    employeeDao = new EmployeeDao();

                return employeeDao;
            }
        }

        private DailyExpenseDao dailyExpenseDao = null;

        private DailyExpenseDao DailyExpenseDao
        {
            get
            {

                if (dailyExpenseDao == null)
                    dailyExpenseDao = new DailyExpenseDao();

                return dailyExpenseDao;
            }
        }



        #endregion

        #region < Metodos >

        public List<CostCenter> ListCostCenter()
        {
            return CostCenterDao.ListarTodos().ToList();
        }

        public CostCenter InsertCostCenter(string denomination, string description)
        {
            CostCenter oCostCenter = new CostCenter()
                                         {
                                             Denomination = denomination,
                                             Description = description
                                         };

            return CostCenterDao.Crear(oCostCenter);
        }

        public CostCenter UpdateCostCenter(int id, string denomination, string description)
        {
            CostCenter oCostCenter = new CostCenter()
                                         {
                                             Id = id,
                                             Denomination = denomination,
                                             Description = description
                                         };

            return CostCenterDao.Modificar(oCostCenter);
        }

        public CostCenter DeleteCostCenter(int id)
        {

            CostCenter oCostCenter = new CostCenter()
                                         {
                                             Id = id,
                                         };

            CostCenterDao.Eliminar(oCostCenter);
            return oCostCenter;
        }

        public CostCenter GetCostCenter(int id)
        {
            return CostCenterDao.Obtener(id);
        }

        public List<CostConcept> ListCostConcept()
        {
            return CostConceptDao.ListarTodos().ToList();
        }

        public CostConcept InsertCostConcept(string code, string description)
        {
            CostConcept oCostConcept = new CostConcept()
                                           {
                                               Code = code,
                                               Description = description
                                           };

            return CostConceptDao.Crear(oCostConcept);
        }

        public CostConcept UpdateCostConcept(int id, string code, string description)
        {
            CostConcept oCostConcept = new CostConcept()
                                           {
                                               Id = id,
                                               Code = code,
                                               Description = description
                                           };

            return CostConceptDao.Modificar(oCostConcept);
        }

        public CostConcept DeleteCostConcept(int id)
        {

            CostConcept oCostConcept = new CostConcept()
                                           {
                                               Id = id,
                                           };

            CostConceptDao.Eliminar(oCostConcept);
            return oCostConcept;
        }

        public CostConcept GetCostConcept(int id)
        {
            return CostConceptDao.Obtener(id);
        }


        public List<Employee> ListEmployee()
        {
            return EmployeeDao.ListarTodos().ToList();
        }

        public Employee InsertEmployee(string name)
        {
            Employee oEmployee = new Employee()
                                     {
                                         Name = name
                                     };

            return EmployeeDao.Crear(oEmployee);
        }

        public Employee UpdateEmployee(int id, string name)
        {
            Employee oEmployee = new Employee()
                                     {
                                         Id = id,
                                         Name = name
                                     };

            return EmployeeDao.Modificar(oEmployee);
        }

        public Employee DeleteEmployee(int id)
        {

            Employee oEmployee = new Employee()
                                     {
                                         Id = id,
                                     };

            EmployeeDao.Eliminar(oEmployee);
            return oEmployee;
        }

        public Employee GetEmployee(int id)
        {
            return EmployeeDao.Obtener(id);
        }

        public List<DailyExpense> ListDailyExpense()
        {
            return DailyExpenseDao.ListarTodos().ToList();
        }

        public DailyExpense InsertDailyExpense(string name)
        {
        
            DailyExpense oDailyExpense = new DailyExpense()
            {
            };            
             
            return DailyExpenseDao.Crear(oDailyExpense);
        }

        public DailyExpense UpdateDailyExpense(int id, string name)
        {
           
            DailyExpense oDailyExpense = new DailyExpense()
            {
            };

            return DailyExpenseDao.Modificar(oDailyExpense);
            
        }

        public DailyExpense DeleteDailyExpense(int id)
        {
           
            DailyExpense oDailyExpense = new DailyExpense()
            {
            };

            DailyExpenseDao.Eliminar(oDailyExpense);
            return oDailyExpense;
            
        }

        public DailyExpense GetDailyExpense(int id)
        {
            return DailyExpenseDao.Obtener(id);
        }
    }

    #endregion
}
